import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
}

response = requests.get('http://www.baidu.com', headers=headers)
print(response.request.headers)  # 打印请求头
print(response.text)  # 百度首页前端源代码

